# coding=utf-8

"""
    @header create_flask.py
    @abstract   
    
    @MyBlog: http://www.kuture.com.cn
    @author  Created by Kuture on 2021/8/10
    @version 1.0.0 2021/8/10 Creation()
    
    @Copyright © 2021年 Mr.Li All rights reserved
"""
import os
import sys
import shutil
import base64
import argparse
from datetime import datetime


pars = argparse.ArgumentParser(description='Create Flask Project')
pars.add_argument('--proj_name', type=str, default='MyProject', help='Project Name, Default Is MyProject!')
pars.add_argument('--proj_dir', default=None, help='Project Dir Path, Default Is None')
args = pars.parse_args()


class AKFlask(object):

    def __init__(self, project_name, project_dir=None):

        dir_name, file = os.path.split(os.path.abspath(sys.argv[0]))
        if (project_dir is None) or (not os.path.exists(project_dir)):self._project_name = os.path.join(dir_name, project_name)
        else:self._project_name = os.path.join(project_dir, project_name)

        self._server_log_base_str = 'IyBjb2Rpbmc9dXRmLTgKCiIiIgogICAgQGhlYWRlciBTZXJ2ZXJfbG9nLnB5CiAgICBAYWJzdHJhY3QgICAKICAgIAogICAgQE15QmxvZzogaHR0cDovL3d3dy5rdXR1cmUuY29tLmNuCiAgICBAYXV0aG9yICBDcmVhdGVkIGJ5IEt1dHVyZSBvbiAyMDIxLzgvOQogICAgQHZlcnNpb24gMS4wLjAgMjAyMS84LzkgQ3JlYXRpb24oKQogICAgCiAgICBAQ29weXJpZ2h0IMKpIDIwMjHlubQgTXIuTGkgQWxsIHJpZ2h0cyByZXNlcnZlZAoiIiIKaW1wb3J0IGxvZ2dpbmcKZnJvbSBsb2dnaW5nIGltcG9ydCBoYW5kbGVycwoKbGV2ZWxfcmVsYXRpb25zID0gewogICAgJ2RlYnVnJzogbG9nZ2luZy5ERUJVRywKICAgICdpbmZvJzogbG9nZ2luZy5JTkZPLAogICAgJ3dhcm5pbmcnOiBsb2dnaW5nLldBUk5JTkcsCiAgICAnZXJyb3InOiBsb2dnaW5nLkVSUk9SLAogICAgJ2NyaXQnOiBsb2dnaW5nLkNSSVRJQ0FMCn0gICMgbG9nIGxldmVsIGRpY3QKCnBy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Z2VuZXJhdGUgZmlsZQogICAgICAgICMgdGggPSBoYW5kbGVycy5UaW1lZFJvdGF0aW5nRmlsZUhhbmRsZXIoZmlsZW5hbWU9ZmlsZW5hbWUsIHdoZW49d2hlbiwgYmFja3VwQ291bnQ9YmFja0NvdW50LAogICAgICAgICMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2Rpbmc9J3V0Zi04JykKICAgICAgICAjIHRoLnNldEZvcm1hdHRlcihmb3JtYXRfc3RyKSAgIyBzZXR0aW5nIHdyaXRpbmcgZm9tYXRlCgogICAgICAgICMgYXV0byBnZW5lcmF0ZSBmaWxlIGZvciBjb250cm9sIGZpbGUgc2l6ZSBhbmQgY291bnQKICAgICAgICBzaXplX3RoID0gaGFuZGxlcnMuUm90YXRpbmdGaWxlSGFuZGxlcihmaWxlbmFtZSwgbWF4Qnl0ZXM9NSoxMDI0KjEwMjQsIGJhY2t1cENvdW50PWJhY2tDb3VudCkKICAgICAgICBzaXplX3RoLnNldEZvcm1hdHRlcihmb3JtYXRfc3RyKQoKICAgICAgICAjIGFkZCBvYmplY3QgdG8gbG9nZ2VyCiAgICAgICAgc2VsZi5sb2dnZXIuYWRkSGFuZGxlcihzaXplX3RoICkgICMgc2l6ZSBmb3JtYXQKICAgICAgICAjIHNlbGYubG9nZ2VyLmFkZEhhbmRsZXIodGgpICAjIHRpbWUgZm9ybWF0CiAgICAgICAgc2VsZi5sb2dnZXIuYWRkSGFuZGxlcihzaCk='
        self._server_conf_base_str = 'IyBjb2Rpbmc9dXRmLTgKIiIiCiAgICBAaGVhZGVyIGNvbmZpZy5weQogICAgQGFic3RyYWN0ICAgCiAgICAKICAgIEBNeUJsb2c6IGh0dHA6Ly93d3cua3V0dXJlLmNvbS5jbgogICAgQGF1dGhvciAgQ3JlYXRlZCBieSBLdXR1cmUgb24gMjAyNC0wMS0zMQogICAgQHZlcnNpb24gMS4wLjAgMjAyNC0wMS0zMSBDcmVhdGlvbigpCiAgICAKIC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2FwcC5yb3V0ZSgnLycsIG1ldGhvZHM9WydQT1NUJ10pCmRlZiBpbmRleCgpOgogICAgbG9nLmxvZ2dlci5pbmZvKCdbIDIwMDAxIF0gLSBNYWluIEFwcCBJbmRleCBVcmwgUE9TVCBSZXF1ZXN0Li4uJykKICAgIHRyeToKICAgICAgICBwb3N0X3BhcmFtZXRlciA9IGpzb24ubG9hZHMocmVxdWVzdC5nZXRfZGF0YSgpKQogICAgICAgIGxvZy5sb2dnZXIuaW5mbygnWyAyMDAwMiBdIC0gTWFpbiBBcHAgSW5kZXggUE9TVCBQYXJhbWV0ZXI6e30nLmZvcm1hdChzdHIocG9zdF9wYXJhbWV0ZXIpWzo2OF0pKQoKICAgICAgICByZXNwb25zZV9yZXMgPSAnJwogICAgICAgIGxvZy5sb2dnZXIuaW5mbygnWyAyMDAwNSBdIC0gTWFpbiBBcHAgSW5kZXggUmVzcG9uc2UuLi4nKQogICAgZXhjZXB0IEV4Y2VwdGlvbiBhcyBlcnJvcjoKICAgICAgICBlcnJvcl9tc2cgPSAnWyAyMDAwMyBdIC0gTWFpbiBBcHAgSW5kZXggVXJsIFBPU1QgUmVxdWVzdCBFcnJvcjp7fScuZm9ybWF0KGVycm9yKQogICAgICAgIHJldHVybiB0b29scy5jcm9zc19kb21haW4oeyJjb2RlIjogY29uZmlnLkVSUk9SLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJtZXNzYWdlIjogZXJyb3JfbXNnfSkKICAgIGVsc2U6CiAgICAgICAgcmV0dXJuIHRvb2xzLmNyb3NzX2RvbWFpbihyZXNwb25zZV9yZXMpCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoK'
        self._server_manager_base_str = 'IyBjb2Rpbmc9dXRmLTgKCiIiIgogICAgQGhlYWRlciBtYW5hZ2VyLnB5CiAgICBAYWJzdHJhY3QKCiAgICBATXlCbG9nOiBodHRwOi8vd3d3Lmt1dHVyZS5jb20uY24KICAgIEBhdXRob3IgIENyZWF0Z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pZy5ERUZBVUxUX1BPUlQpKQoKICAgICAgICBhcmdzID0gcGFyYXNlci5wYXJzZV9hcmdzKCkKICAgICAgICBzZXJ2ZXJfaXAgPSBhcmdzLmlwCiAgICAgICAgc2VydmVyX3BvcnQgPSBhcmdzLnBvcnQKICAgICAgICBsb2cubG9nZ2VyLmluZm8oJ1sgMDAwMTEgXSAtIFNlcnZlciBJUDp7fSBQb3J0Ont9IFZlcnNpb246e30nLmZvcm1hdChzZXJ2ZXJfaXAsIHNlcnZlcl9wb3J0LCBjb25maWcuQ0FSX1ZFUlNJT04pKQoKICAgICAgICBtYWluKHNlcnZlcl9pcCwgc2VydmVyX3BvcnQpCiAgICBleGNlcHQgRXhjZXB0aW9uIGFzIGVycm9yOgogICAgICAgIGxvZy5sb2dnZXIuY3JpdGljYWwoJ1sgU2VydmVyIFN0YXJ0IEZhaWxlZCBdIC0ge30nLmZvcm1hdChlcnJvcikpCiAgICBmaW5hbGx5OgogICAgICAgICMgS2lsbGVkIFNlcnZlciBBZnRlciBDbG9zZWQKICAgICAgICBwcmludCgne30gWyBBbGwgUHJvY2Vzc2VzIEhhdmUgQmVlbiBLaWxsZWQgXSB7fScuZm9ybWF0KCctJyo1MCwgJy0nKjUwKSkKICAgICAgICBraWxsZWRfbWFuYWdlcl90aGQoKQoKCgoKCgoKCgoKCg=='

        print(self._generate_print_str('创建工程 {}'.format(self._project_name)))
        if os.path.exists(self._project_name):
            input_str = input('{} is exist, recover or not(y/n)'.format(self._project_name))
            if input_str.lower() == 'y':
                shutil.rmtree(self._project_name)
        os.mkdir(self._project_name)

    # generate print str
    def _generate_print_str(self, label_str):
        new_label = '{}{}'.format('-' * (50 - len(label_str)), label_str)
        return new_label

    # generate python file
    def _generate_file(self, file_path, file_content):

        if isinstance(file_content, bytes):file_content = file_content.decode()
        file_content = file_content.replace('2021/8/9', '{}'.format(str(datetime.now()).split()[0]))
        with open(file_path, 'w') as sf:
            sf.write(file_content)

    # create Modules
    def _create_modules(self):
        print(self._generate_print_str('创建模块 Modules'))
        modules_path = os.path.join(self._project_name, 'Modules')
        modules_init_path = os.path.join(modules_path, '__init__.py')
        modules_log_path = os.path.join(modules_path, 'Server_log.py')

        os.mkdir(modules_path)
        self._generate_file(modules_init_path, '')
        self._generate_file(modules_log_path, base64.b64decode(self._server_log_base_str))

    # create Package
    def _create_package(self):
        print(self._generate_print_str('创建模块 Package'))
        package_path = os.path.join(self._project_name, 'Package')
        package_init_path = os.path.join(package_path, '__init__.py')

        os.mkdir(package_path)
        self._generate_file(package_init_path, '')

    # create app
    def _create_app(self):

        print(self._generate_print_str('创建模块 APP'))
        app_path = os.path.join(self._project_name, 'APP')
        app_main_dir_path = os.path.join(app_path, 'Main')
        app_main_init_path = os.path.join(app_main_dir_path, '__init__.py')
        app_main_views_path = os.path.join(app_main_dir_path, 'views.py')

        os.mkdir(app_path)
        os.mkdir(app_main_dir_path)
        self._generate_file(app_main_init_path, '')
        self._generate_file(app_main_views_path, base64.b64decode(self._server_views_base_str))

    # create config file
    def _create_config(self):

        print(self._generate_print_str('创建文件 config'))
        config_path = os.path.join(self._project_name, 'config.py')
        self._generate_file(config_path, base64.b64decode(self._server_conf_base_str))

    # create manager file
    def _create_manager(self):

        print(self._generate_print_str('创建文件 manager'))
        manager_path = os.path.join(self._project_name, 'manager.py')
        self._generate_file(manager_path, base64.b64decode(self._server_manager_base_str))

    # create all
    def main_create(self):
        self._create_modules()
        self._create_package()
        self._create_app()
        self._create_config()
        self._create_manager()


if __name__ == '__main__':

    create_obj = AKFlask(args.proj_name, args.proj_dir)
    create_obj.main_create()

















